﻿// Decompiled with JetBrains decompiler
// Type: UnityEngine.Rendering.CameraProperties
// Assembly: UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E6AE6B5A-2752-4B07-9528-C8B77C62CE79
// Assembly location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
// XML documentation location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.xml

using System;
using UnityEngine.Scripting;

#nullable disable
namespace UnityEngine.Rendering
{
  /// <summary>
  ///   <para>Camera related properties in CullingParameters.</para>
  /// </summary>
  [UsedByNativeCode]
  public struct CameraProperties : IEquatable<CameraProperties>
  {
    private const int k_NumLayers = 32;
    private Rect screenRect;
    private Vector3 viewDir;
    private float projectionNear;
    private float projectionFar;
    private float cameraNear;
    private float cameraFar;
    private float cameraAspect;
    private Matrix4x4 cameraToWorld;
    private Matrix4x4 actualWorldToClip;
    private Matrix4x4 cameraClipToWorld;
    private Matrix4x4 cameraWorldToClip;
    private Matrix4x4 implicitProjection;
    private Matrix4x4 stereoWorldToClipLeft;
    private Matrix4x4 stereoWorldToClipRight;
    private Matrix4x4 worldToCamera;
    private Vector3 up;
    private Vector3 right;
    private Vector3 transformDirection;
    private Vector3 cameraEuler;
    private Vector3 velocity;
    private float farPlaneWorldSpaceLength;
    private uint rendererCount;
    private const int k_PlaneCount = 6;
    internal unsafe fixed byte m_ShadowCullPlanes[96];
    internal unsafe fixed byte m_CameraCullPlanes[96];
    private float baseFarDistance;
    private Vector3 shadowCullCenter;
    internal unsafe fixed float layerCullDistances[32];
    private int layerCullSpherical;
    private CoreCameraValues coreCameraValues;
    private uint cameraType;
    private int projectionIsOblique;
    private int isImplicitProjectionMatrix;

    /// <summary>
    ///   <para>Get a shadow culling plane.</para>
    /// </summary>
    /// <param name="index">Plane index (up to 5).</param>
    /// <returns>
    ///   <para>Shadow culling plane.</para>
    /// </returns>
    public unsafe Plane GetShadowCullingPlane(int index)
    {
      if (index < 0 || index >= 6)
        throw new ArgumentOutOfRangeException(string.Format("{0} was {1}, but must be at least 0 and less than {2}", (object) nameof (index), (object) index, (object) 6));
      fixed (byte* numPtr = this.m_ShadowCullPlanes)
        return *(Plane*) (numPtr + ((IntPtr) index * sizeof (Plane)).ToInt64());
    }

    /// <summary>
    ///   <para>Set a shadow culling plane.</para>
    /// </summary>
    /// <param name="index">Plane index (up to 5).</param>
    /// <param name="plane">Shadow culling plane.</param>
    public unsafe void SetShadowCullingPlane(int index, Plane plane)
    {
      if (index < 0 || index >= 6)
        throw new ArgumentOutOfRangeException(string.Format("{0} was {1}, but must be at least 0 and less than {2}", (object) nameof (index), (object) index, (object) 6));
      fixed (byte* numPtr = this.m_ShadowCullPlanes)
        *(Plane*) (numPtr + ((IntPtr) index * sizeof (Plane)).ToInt64()) = plane;
    }

    /// <summary>
    ///   <para>Get a camera culling plane.</para>
    /// </summary>
    /// <param name="index">Plane index (up to 5).</param>
    /// <returns>
    ///   <para>Camera culling plane.</para>
    /// </returns>
    public unsafe Plane GetCameraCullingPlane(int index)
    {
      if (index < 0 || index >= 6)
        throw new ArgumentOutOfRangeException(string.Format("{0} was {1}, but must be at least 0 and less than {2}", (object) nameof (index), (object) index, (object) 6));
      fixed (byte* numPtr = this.m_CameraCullPlanes)
        return *(Plane*) (numPtr + ((IntPtr) index * sizeof (Plane)).ToInt64());
    }

    /// <summary>
    ///   <para>Set a camera culling plane.</para>
    /// </summary>
    /// <param name="index">Plane index (up to 5).</param>
    /// <param name="plane">Camera culling plane.</param>
    public unsafe void SetCameraCullingPlane(int index, Plane plane)
    {
      if (index < 0 || index >= 6)
        throw new ArgumentOutOfRangeException(string.Format("{0} was {1}, but must be at least 0 and less than {2}", (object) nameof (index), (object) index, (object) 6));
      fixed (byte* numPtr = this.m_CameraCullPlanes)
        *(Plane*) (numPtr + ((IntPtr) index * sizeof (Plane)).ToInt64()) = plane;
    }

    public unsafe bool Equals(CameraProperties other)
    {
      for (int index = 0; index < 6; ++index)
      {
        if (!this.GetShadowCullingPlane(index).Equals((object) other.GetShadowCullingPlane(index)))
          return false;
      }
      for (int index = 0; index < 6; ++index)
      {
        if (!this.GetCameraCullingPlane(index).Equals((object) other.GetCameraCullingPlane(index)))
          return false;
      }
      fixed (float* numPtr = this.layerCullDistances)
      {
        for (int index = 0; index < 32; ++index)
        {
          if ((double) numPtr[index] != (double) other.layerCullDistances[index])
            return false;
        }
      }
      return this.screenRect.Equals(other.screenRect) && this.viewDir.Equals(other.viewDir) && this.projectionNear.Equals(other.projectionNear) && this.projectionFar.Equals(other.projectionFar) && this.cameraNear.Equals(other.cameraNear) && this.cameraFar.Equals(other.cameraFar) && this.cameraAspect.Equals(other.cameraAspect) && this.cameraToWorld.Equals(other.cameraToWorld) && this.actualWorldToClip.Equals(other.actualWorldToClip) && this.cameraClipToWorld.Equals(other.cameraClipToWorld) && this.cameraWorldToClip.Equals(other.cameraWorldToClip) && this.implicitProjection.Equals(other.implicitProjection) && this.stereoWorldToClipLeft.Equals(other.stereoWorldToClipLeft) && this.stereoWorldToClipRight.Equals(other.stereoWorldToClipRight) && this.worldToCamera.Equals(other.worldToCamera) && this.up.Equals(other.up) && this.right.Equals(other.right) && this.transformDirection.Equals(other.transformDirection) && this.cameraEuler.Equals(other.cameraEuler) && this.velocity.Equals(other.velocity) && this.farPlaneWorldSpaceLength.Equals(other.farPlaneWorldSpaceLength) && (int) this.rendererCount == (int) other.rendererCount && this.baseFarDistance.Equals(other.baseFarDistance) && this.shadowCullCenter.Equals(other.shadowCullCenter) && this.layerCullSpherical == other.layerCullSpherical && this.coreCameraValues.Equals(other.coreCameraValues) && (int) this.cameraType == (int) other.cameraType && this.projectionIsOblique == other.projectionIsOblique && this.isImplicitProjectionMatrix == other.isImplicitProjectionMatrix;
    }

    public override bool Equals(object obj)
    {
      return obj != null && obj is CameraProperties other && this.Equals(other);
    }

    public override unsafe int GetHashCode()
    {
      int num1 = ((((((((((((((((((((this.screenRect.GetHashCode() * 397 ^ this.viewDir.GetHashCode()) * 397 ^ this.projectionNear.GetHashCode()) * 397 ^ this.projectionFar.GetHashCode()) * 397 ^ this.cameraNear.GetHashCode()) * 397 ^ this.cameraFar.GetHashCode()) * 397 ^ this.cameraAspect.GetHashCode()) * 397 ^ this.cameraToWorld.GetHashCode()) * 397 ^ this.actualWorldToClip.GetHashCode()) * 397 ^ this.cameraClipToWorld.GetHashCode()) * 397 ^ this.cameraWorldToClip.GetHashCode()) * 397 ^ this.implicitProjection.GetHashCode()) * 397 ^ this.stereoWorldToClipLeft.GetHashCode()) * 397 ^ this.stereoWorldToClipRight.GetHashCode()) * 397 ^ this.worldToCamera.GetHashCode()) * 397 ^ this.up.GetHashCode()) * 397 ^ this.right.GetHashCode()) * 397 ^ this.transformDirection.GetHashCode()) * 397 ^ this.cameraEuler.GetHashCode()) * 397 ^ this.velocity.GetHashCode()) * 397 ^ this.farPlaneWorldSpaceLength.GetHashCode()) * 397 ^ (int) this.rendererCount;
      for (int index = 0; index < 6; ++index)
        num1 = num1 * 397 ^ this.GetShadowCullingPlane(index).GetHashCode();
      for (int index = 0; index < 6; ++index)
        num1 = num1 * 397 ^ this.GetCameraCullingPlane(index).GetHashCode();
      int num2 = (num1 * 397 ^ this.baseFarDistance.GetHashCode()) * 397 ^ this.shadowCullCenter.GetHashCode();
      fixed (float* numPtr = this.layerCullDistances)
      {
        for (int index = 0; index < 32; ++index)
          num2 = num2 * 397 ^ numPtr[index].GetHashCode();
      }
      return ((((num2 * 397 ^ this.layerCullSpherical) * 397 ^ this.coreCameraValues.GetHashCode()) * 397 ^ (int) this.cameraType) * 397 ^ this.projectionIsOblique) * 397 ^ this.isImplicitProjectionMatrix;
    }

    public static bool operator ==(CameraProperties left, CameraProperties right)
    {
      return left.Equals(right);
    }

    public static bool operator !=(CameraProperties left, CameraProperties right)
    {
      return !left.Equals(right);
    }
  }
}
